package cn.itheima.service.impl;

import cn.itheima.dao.AreaRepository;
import cn.itheima.domain.Area;
import cn.itheima.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by millions on 2017/7/3.
 */
@Service
@Transactional
public class AreaServiceImpl implements AreaService{

    @Autowired
    private AreaRepository areaRepository;

    @Override
    public void batchSave(List<Area> areaList) {
        areaRepository.save(areaList);
    }

    @Override
    public Page<Area> queryByPage(Pageable pageable) {
        return areaRepository.findAll(pageable);
    }

    @Override
    public Page<Area> queryPageDateBySpection(Specification<Area> specification, Pageable pageable) {

        return areaRepository.findAll(specification,pageable);
    }


    @Override
    public List<Area> findAll(List<String> ids) {
        return areaRepository.findAll(ids);
    }

    @Override
    public void deleteArea(List<Area> areaList) {
        areaRepository.delete(areaList);
    }
}
